﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations.Schema;

namespace DuToanT2.Models.Mapping
{
    public class HangMuc_CongViecMap : EntityTypeConfiguration<HangMuc_CongViec>
    {
        public HangMuc_CongViecMap()
        { 
            // key
            HasKey(t => t.ID);

            // properties
            Property(t => t.ID);
            Property(t => t.KhoiLuong);

            // table
            ToTable("HangMuc_CongViec");

            // relationship
            HasRequired(t => t.HangMuc)
                .WithMany(c => c.HangMuc_CongViecs)
                .HasForeignKey(t => t.HangMucId)
                .WillCascadeOnDelete(true);
            HasOptional(t => t.DinhMuc_CongViec)
                .WithMany(c => c.HangMuc_CongViecs)
                .HasForeignKey(t => t.DinhMuc_CongViecId)
                .WillCascadeOnDelete(true);
        }
    }
}
